package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * The type Shop controller.
 */
@Api(tags = "营业状态")
@RequestMapping("/user/shop")
@RestController("userShopController")
@Slf4j
@RequiredArgsConstructor
public class ShopController {

    private final String key = "SHOP_STATUS";

    private final RedisTemplate redisTemplate;


    /**
     * 获取店铺营业状态
     *
     * @return the result
     */
    @ApiOperation("获取店铺营业状态")
    @GetMapping("/status")
    public Result<Integer> readStatus(){
        Integer status = (Integer) redisTemplate.opsForValue().get(key);
        log.info("营业状态为:"+(status==1?"营业中":"打烊了"));
        return Result.success(status);
    }


}
